const setLocalStorage = (key, val) => {
    if (val instanceof Array || val instanceof Object) {
        val = JSON.stringify(val)
    }
    localStorage.setItem(key, val)
}

const getLocalStorage = (key) => {
    let val = localStorage.getItem(key);
    let reg = /^[[{].*[\]}]$/;
    if (reg.test(val)) {
        val = JSON.parse(val)
    }
    return val
}

export { getLocalStorage, setLocalStorage }